package feed

import (
	"time"
)

type SetFeed struct {
	entries map[string]FeedEntry
	count int
}

func NewSetFeed() *SetFeed {
	return &SetFeed{make(map[string]FeedEntry), 0}
}

func (q *SetFeed) SinceTime(t time.Time) (entries BasicFeed) {

	for _,v := range q.entries {
		if v.Time.After(t) {
			entries = append(entries, v)
		}
	}

	return
}

func (q *SetFeed) Since(pos int) (entries BasicFeed) {

	for _,v := range q.entries {
		if v.Index > pos {
			entries = append(entries, v)
		}
	}

	return
}

func (q *SetFeed) Add(e string, at time.Time) {

	q.entries[e] = FeedEntry{q.count, e, at}

	q.count++
}
